<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/19
  Time: 15:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="bean.Student" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    if (session.isNew() || session.getAttribute("user") == null) {
        response.sendRedirect("/index.jsp");
        return;
    }
    if(session.getAttribute("studentList") == null){
        response.sendRedirect("/studentAllServlet");
        return;
    }
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>学生选课管理后台-首页</title>
    <jsp:include page="/conme/hd.jsp" flush="true" />
            <!--开始::内容-->
            <div class="clear mt-20 mr-15 ml-15">
                <div class="fl">
                    <button class="btn btn-warning" onclick="location.href = 'addStudent.jsp' "><i class="icon-cog"></i>新增</button>
                    <button class="btn btn-danger" onclick="nudop()"><i class="icon-trash"></i>删除</button>
                    <button class="btn btn-disabled" onclick="location.href = '/studentAllServlet' "><i class="icon-remove-sign"></i>更新</button>
                </div>
                <div class="fr input-group">
                    <form action="search" method="get">
                        <input type="text" class="form-control" name="sname" placeholder="用户姓名" style="width:290px;"/>
                        <button class="btn btn-secondary">搜索</button>
                    </form>
                </div>
            </div>
            <table class="table table-bordered mr-15 ml-15 mt-15">
                <thead>
                <tr class="cen">
                    <th>学号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>所在系</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="list">
                <c:forEach items="${studentList}" var="st">
                    <tr class="cen">
                        <td>${st.sno}</td>
                        <td>${st.sname}</td>
                        <td>${st.ssex}</td>
                        <td>${st.sage}</td>
                        <td>${st.sdept}</td>
                        <td>
                            <a href="updateStudent?sno=${st.sno}">修改</a>
                            <a onclick="deletop(${st.sno})">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div class="pagination fr"></div>
            <!--结束::内容-->
            <jsp:include page="/conme/foot.jsp" flush="true" />
</body>
<script>
    //待开发提示
    function nudop(){
        alert("联系月月开发吧！")
    }
    ///删除
    function deletop(id){
        layer.confirm('确定删除用户吗？', {
            title:'系统提示',
            btn: ['确定','取消']
        }, function(){
            location.href = 'Delete?sno='+id;
        });
    }
</script>
</html>
